﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Azku.Common
{
    /// <summary>
    /// 错误日志
    /// </summary>
    /// <param name="errMsg"></param>
    public delegate void ErrorLog(string errMsg);

    /// <summary>
    /// 消息基类
    /// </summary>
    [Serializable]
    public abstract class MessageBase
    {
    }
    /// <summary>
    /// 服务端发送到客户端的消息
    /// </summary>
    [Serializable]
    public abstract class STCMessageBase : MessageBase
    {

    }
    /// <summary>
    /// 客户端发送到服务端的消息
    /// </summary>
    [Serializable]
    public abstract class CTSMessageBase : MessageBase
    {
        public System.Net.IPEndPoint M_IPEndPoint { get; set; }
        public User M_User { get; set; }

        public CTSMessageBase() { }
    }
    /// <summary>
    /// 用户登录
    /// </summary>
    [Serializable]
    public class CTSUserLogin : CTSMessageBase
    {

        public CTSUserLogin(string userName, string userPwd)
        {
            M_User = new User() { UserName = userName, UserPwd = userPwd };
        }
    }
    /// <summary>
    /// 用户登出
    /// </summary>
    [Serializable]
    public class CTSUserLogout : CTSMessageBase
    {
        public CTSUserLogout(string userName)
        {
            M_User = new User() { UserName = userName };
        }
    }
    [Serializable]
    public class CTSGetOnLineList : CTSMessageBase
    {
        public CTSGetOnLineList(string userName)
        {
            M_User = new User() { UserName = userName };
        }
    }

    /// <summary>
    /// 客户端发送到客户端的消息
    /// </summary>
    [Serializable]
    public abstract class CTCMessageBase : MessageBase
    {

    }

    [Serializable]
    public class MessageCollection : System.Collections.CollectionBase
    {
        public void Insert(MessageBase msg)
        {
            base.OnInsert(this.Count, msg);
        }

        public void Delete(MessageBase msg)
        {
            for (int i = 0; i < Count; i++)
            {
                if (this[i] == msg)
                {
                    base.RemoveAt(i);
                }
            }
        }

        public MessageBase this[int index]
        {
            get
            {
                return (MessageBase)this.List[index];
            }
        }

    }
}
